package com.mindskip.xzs.controller.wx.student;

import com.mindskip.xzs.base.BaseApiController;
import com.mindskip.xzs.base.RestResponse;
import com.mindskip.xzs.domain.WxSafetyRainingRecord;
import com.mindskip.xzs.service.WxSafetyRainingRecordService;
import com.mindskip.xzs.viewmodel.wx.student.user.WxSafetyRainingRecordUpdateVM;
import com.mindskip.xzs.viewmodel.wx.student.user.WxVehicleInspectionUpdateVM;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @Author zhangshunan
 * @Date 2021/11/25
 */
@RestController("WXStudentWxSafetyRainingRecordController")
@RequestMapping(value = {"/api/student/safetyRainingRecord","/api/wx/safetyRainingRecord"})
public class WxSafetyRainingRecordController extends BaseApiController {

    @Autowired
    WxSafetyRainingRecordService wxSafetyRainingRecordService;

    @RequestMapping(value = "/add", method = RequestMethod.POST)
    public RestResponse add(@RequestBody @Valid WxSafetyRainingRecordUpdateVM model) {
        wxSafetyRainingRecordService.add(model);
        return RestResponse.ok();
    }

    //手机号查询一条最新记录
    @RequestMapping(value = "/getOneRecordByPhone", method = RequestMethod.GET)
    public RestResponse<WxSafetyRainingRecord> getOneRecordByPhone(@RequestParam(value = "phone") String phone) {
        WxSafetyRainingRecord obj = wxSafetyRainingRecordService.getOneRecordByPhone(phone);
        return RestResponse.ok(obj);
    }
}
